Public Class Report
    Dim ReportDataSource As New Microsoft.Reporting.WinForms.ReportDataSource
    Public StartDate, EndDate As Date
    Public active As Boolean
    Public couponlimit As Double
    Public RType As String
    Public EmployeeID As String

    Private Sub Report_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Me.Dispose()
    End Sub

    Private Sub Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        Try
            Select Case RType
                Case "TOTAL"
                    Me.Width = 740
                    'ReportDataSource.Name = "Canteen_EmployeeDataTable"
                    ReportDataSource.Name = "CanteenDataSet_RCoupon"
                    ReportDataSource.Value = db.getReport(StartDate, EndDate, couponlimit).Tables(0) 'db.getStoredProcedure("RCoupon").Tables(0) 'db.getvalue("select employeeID,eFullName,eDepartment from employee").Tables(0)

                    Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource)
                    Me.ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\Report\SummaryReport.rdlc"
                    Me.ReportViewer1.RefreshReport()
                Case "DETAIL"
                    Me.Width = 300
                    ReportDataSource.Name = "CANTEENDataSet1_transactionsOfID"
                    ReportDataSource.Value = db.getDetailReport(StartDate, EndDate, EmployeeID).Tables(0) 'db.getStoredProcedure("RCoupon").Tables(0) 'db.getvalue("select employeeID,eFullName,eDepartment from employee").Tables(0)

                    Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource)
                    Me.ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\Report\detailReport.rdlc"
                    Me.ReportViewer1.RefreshReport()
            End Select
            


        Catch ex As Exception

            MsgBox("Error submitting data. Error Message: " & ex.Message & " Stack Trace: " & ex.StackTrace)

        End Try

    End Sub


End Class